<script>
export default {
  /* setup执行时机，setup先执行，然后beforeCreate最后created
  setup () {
    console.log('setup执行了')
  },
  beforeCreate () {
    console.log('beforeCreate执行了')
  },
  created() {
    console.log('created执行了')
  } */
 setup() {
  const msg = 'this is message'
  const logMsg = () => {
    console.log(msg)
  }
  //setup方法中声明的数据或者方法必须return才能被模板使用
  return {
    msg,
    logMsg
  }
 }
}
</script>
<template>
  <div>
    <div>msg: {{ msg }}</div>
    <button @click="logMsg">打印msg</button>
  </div>
</template>

<style lang="scss" scoped>

</style>
